package com.tyylab.message.core.service;

import io.lettuce.core.api.StatefulRedisConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class ChannelCheckService implements IChannelCheck {
    @Autowired
    @Qualifier("readConn")
    StatefulRedisConnection<String,String> redisConnection;
    @Override
    public long sizeOf(String channel) {
        if (redisConnection.sync().exists(channel)<=0){
            return 0;
        }
        else {
            return redisConnection.sync().llen(channel);
        }
    }
}
